
package Controllers;

import java.rmi.RemoteException;

import Common.Helper;
import Models.ChessPieceModel;
import Models.Point2D;
import Models.StandardChessPieceModel;

public class QueenController implements ChessPieceControllerInterface {

	@Override
	public boolean legalMove(Point2D moveVector, ChessPieceModel chessPiece) throws RemoteException {
		if (Math.abs(moveVector.getX()) == Math.abs(moveVector.getY())) {
			return true;
		}
		else if (moveVector.getX() == 0 || moveVector.getY() == 0) {
			return true;
		}
		else {
		return false;
		}
	}

	


	@Override
	public boolean legalCapture(Point2D moveVector, ChessPieceModel chessPiece) throws RemoteException {
		// TODO Auto-generated method stub
		return legalMove(moveVector, chessPiece);
	}

	@Override
	public boolean canPieceMoveNotify(Point2D from, Point2D to,
			ChessPieceModel chessPiece) throws RemoteException {
		return legalMove(Helper.calculateVector(from, to), chessPiece);
		}
		
		
		public static ChessPieceModel getNew() throws RemoteException {
			ChessPieceModel queen = new StandardChessPieceModel();
			ChessPieceControllerInterface queenController = new QueenController();
			queen.addCanPieceMoveListener(queenController);
			return queen;
		}

}
